package com.photographysharing.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.photographysharing.dto.CommentDTO;
import com.photographysharing.dto.ReportDTO;
import com.photographysharing.entity.Reports;
import com.photographysharing.request.SelectByPaging;
import com.photographysharing.response.DatasResponse;
import com.photographysharing.service.ReportsService;
import com.photographysharing.mapper.ReportsMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Z
* @description 针对表【reports】的数据库操作Service实现
* @createDate 2024-06-10 22:57:39
*/
@Service
public class ReportsServiceImpl extends ServiceImpl<ReportsMapper, Reports>
    implements ReportsService{

    private ReportsMapper reportsMapper;

    public ReportsServiceImpl(ReportsMapper reportsMapper) {
        this.reportsMapper = reportsMapper;
    }

    @Override
    public DatasResponse<ReportDTO> selectByPag(SelectByPaging pag) {
        int index = pag.getIndex();
        int size = pag.getSize();
        String name = pag.getSearchName();
        String userName = pag.getSearchValue1();
        int status = Integer.parseInt(pag.getSearchValue2());
        int typeId = Integer.parseInt(pag.getSearchValue3());
        List<ReportDTO> datas= reportsMapper.selectByPag((index-1)*size,size,name,userName,status,typeId);
        int count =reportsMapper.selectByPagCount(name,userName,status,typeId);
        return new DatasResponse<>(count,datas);
    }
}




